package com.aba.hos.doc;


import com.aba.hos.admin.Admin;
import com.aba.hos.dao.AdminDao;
import com.aba.hos.dao.impl.AdminDaoImpl;
import com.aba.hos.doc.entity.Doctor;
import com.aba.hos.doc.entity.Patient;
import com.aba.hos.doc.entity.Ward;
import com.aba.hos.doc.service.HospitalService;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 主程序入口，演示医院管理系统的使用
 */
public class Main {
    private static AdminDao adminDao = new AdminDaoImpl();
    public static void main(String[] args) throws SQLException {
//        // 创建医院服务实例
//        HospitalService hospitalService = new HospitalService();
//
//        List<Admin> adminList = adminDao.queryAdminRole("医生");
//        // 添加医生
//        Doctor doctor1 = new Doctor("张医生", "心脏科");
//        Doctor doctor2 = new Doctor("李医生", "神经科");
//        Doctor doctor3 = new Doctor("王医生", "外科");
//        for (Admin a :  adminList){
//            Doctor an = new Doctor("张医生", "心脏科");
//            hospitalService.addDoctor(an);
//        }
//
//
//        hospitalService.addDoctor(doctor2);
//        hospitalService.addDoctor(doctor3);
//
//        // 添加病房
//        Ward ward1 = new Ward("普通病房", 4);
//        Ward ward2 = new Ward("高级病房", 2);
//        Ward ward3 = new Ward("ICU", 3);
//        hospitalService.addWard(ward1);
//        hospitalService.addWard(ward2);
//        hospitalService.addWard(ward3);
//
//        // 添加病人
//        Patient patient1 = new Patient("张三", 45, "男", "心脏病","4","1");
//        Patient patient2 = new Patient("李四", 32, "男", "偏头痛","4","2");
//        Patient patient3 = new Patient("王五", 56, "女", "骨折","4","3");
//        Patient patient4 = new Patient("赵六", 28, "女", "脑震荡","4","4");
//        Patient patient5 = new Patient("钱七", 62, "男", "心肌梗塞","4","5");
//        hospitalService.addPatient(patient1);
//        hospitalService.addPatient(patient2);
//        hospitalService.addPatient(patient3);
//        hospitalService.addPatient(patient4);
//        hospitalService.addPatient(patient5);
//
//        // 分配医生
//        hospitalService.assignDoctorToPatient(doctor1.getId(), patient1.getId());
//        hospitalService.assignDoctorToPatient(doctor2.getId(), patient2.getId());
//        hospitalService.assignDoctorToPatient(doctor3.getId(), patient3.getId());
//        hospitalService.assignDoctorToPatient(doctor2.getId(), patient4.getId());
//        hospitalService.assignDoctorToPatient(doctor1.getId(), patient5.getId());
//
//        // 分配病房
//        hospitalService.assignPatientToWard(patient1.getId(), ward1.getWardNumber());
//        hospitalService.assignPatientToWard(patient2.getId(), ward1.getWardNumber());
//        hospitalService.assignPatientToWard(patient3.getId(), ward2.getWardNumber());
//        hospitalService.assignPatientToWard(patient4.getId(), ward2.getWardNumber());
//        hospitalService.assignPatientToWard(patient5.getId(), ward3.getWardNumber());
//
//        // 显示统计信息
//        System.out.println("\n===== 医院统计信息 =====");
//        System.out.println("总病人数: " + hospitalService.getTotalPatients());
//        System.out.println("当前住院病人数: " + hospitalService.getActivePatientCount());
//        System.out.println("医生总数: " + hospitalService.getTotalDoctors());
//        System.out.println("病房总数: " + hospitalService.getTotalWards());
//        System.out.println("可用床位: " + hospitalService.getAvailableBeds());
//
//        // 显示病房占用情况
//        System.out.println("\n===== 病房占用情况 =====");
//        Map<String, Integer> wardOccupancy = hospitalService.getWardOccupancy();
//        for (Map.Entry<String, Integer> entry : wardOccupancy.entrySet()) {
//            System.out.println(entry.getKey() + ": " + entry.getValue() + " 名病人");
//        }
//
//        // 显示医生负责病人数量
//        System.out.println("\n===== 医生负责病人数量 =====");
//        Map<String, Integer> doctorPatientCount = hospitalService.getDoctorPatientCount();
//        for (Map.Entry<String, Integer> entry : doctorPatientCount.entrySet()) {
//            System.out.println(entry.getKey() + ": " + entry.getValue() + " 名病人");
//        }
//
//        // 病人出院
//        System.out.println("\n===== 病人出院 =====");
//        hospitalService.dischargePatient(patient2.getId());
//
//        // 重新分配病房
//        System.out.println("\n===== 重新分配病房 =====");
//        hospitalService.assignPatientToWard(patient4.getId(), ward1.getWardNumber());
//
//        // 显示更新后的统计信息
//        System.out.println("\n===== 更新后的统计信息 =====");
//        System.out.println("当前住院病人数: " + hospitalService.getActivePatientCount());
//        System.out.println("可用床位: " + hospitalService.getAvailableBeds());
//
//        System.out.println("\n===== 更新后的病房占用情况 =====");
//        wardOccupancy = hospitalService.getWardOccupancy();
//        for (Map.Entry<String, Integer> entry : wardOccupancy.entrySet()) {
//            System.out.println(entry.getKey() + ": " + entry.getValue() + " 名病人");
//        }
    }
}    